package gui;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JTextField;
import java.awt.TextArea;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class EducationalFrame {

	private JFrame frame;
	private JTextField cycles;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					EducationalFrame window = new EducationalFrame();
					window.frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public EducationalFrame() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frame = new JFrame();
		frame.setBounds(100, 100, 880, 640);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().setLayout(null);
		
		JPanel eduPanel = new JPanel();
		eduPanel.setBounds(10, 11, 844, 580);
		frame.getContentPane().add(eduPanel);
		eduPanel.setLayout(null);
		
		JLabel lblEducationalView = new JLabel("Educational View:");
		lblEducationalView.setFont(new Font("OCR A Extended", Font.BOLD | Font.ITALIC, 16));
		lblEducationalView.setBounds(10, 11, 224, 33);
		eduPanel.add(lblEducationalView);
		
		JLabel lblEnterANumber = new JLabel("Enter a number the number of cycles to simulate.");
		lblEnterANumber.setBounds(81, 45, 405, 14);
		eduPanel.add(lblEnterANumber);
		
		JLabel lblSimulateFor = new JLabel("Simulate for:");
		lblSimulateFor.setBounds(10, 86, 85, 14);
		eduPanel.add(lblSimulateFor);
		
		cycles = new JTextField();
		cycles.setBounds(110, 83, 44, 20);
		eduPanel.add(cycles);
		cycles.setColumns(10);
		
		JLabel lblCycles = new JLabel("cycles");
		lblCycles.setBounds(164, 86, 46, 14);
		eduPanel.add(lblCycles);
		
		TextArea reserveStat = new TextArea();
		reserveStat.setEditable(false);
		reserveStat.setBounds(10, 131, 304, 91);
		eduPanel.add(reserveStat);
		
		JLabel lblReservationStations = new JLabel("Reservation Stations:");
		lblReservationStations.setBounds(10, 111, 157, 14);
		eduPanel.add(lblReservationStations);
		
		JLabel lblCacheLevel1 = new JLabel("Cache Level 1:");
		lblCacheLevel1.setBounds(10, 228, 101, 14);
		eduPanel.add(lblCacheLevel1);
		
		JButton btnSimulate = new JButton("Simulate");
		btnSimulate.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				// call simulate with the specified timing
				// clear the text area 
				// view the RS, ROB, CACHE, MEM, INST.
			}
		});
		btnSimulate.setBounds(225, 82, 89, 23);
		eduPanel.add(btnSimulate);
		
		TextArea cacheLevel1 = new TextArea();
		cacheLevel1.setEditable(false);
		cacheLevel1.setBounds(10, 248, 304, 91);
		eduPanel.add(cacheLevel1);
		
		JLabel lblCacheLevel2 = new JLabel("Cache Level 2:");
		lblCacheLevel2.setBounds(10, 345, 89, 14);
		eduPanel.add(lblCacheLevel2);
		
		TextArea cacheLevel2 = new TextArea();
		cacheLevel2.setEditable(false);
		cacheLevel2.setBounds(10, 365, 304, 82);
		eduPanel.add(cacheLevel2);
		
		JLabel lblCacheLevel3 = new JLabel("Cache Level 3:");
		lblCacheLevel3.setBounds(10, 453, 101, 14);
		eduPanel.add(lblCacheLevel3);
		
		TextArea cacheLevel3 = new TextArea();
		cacheLevel3.setBounds(10, 473, 304, 82);
		eduPanel.add(cacheLevel3);
		
		JLabel lblReorderBuffer = new JLabel("Re-Order Buffer:");
		lblReorderBuffer.setBounds(396, 345, 135, 14);
		eduPanel.add(lblReorderBuffer);
		
		TextArea robs = new TextArea();
		robs.setEditable(false);
		robs.setBounds(396, 365, 380, 82);
		eduPanel.add(robs);
		
		JLabel lblMemory = new JLabel("Memory:");
		lblMemory.setBounds(396, 453, 90, 14);
		eduPanel.add(lblMemory);
		
		TextArea memoryList = new TextArea();
		memoryList.setBounds(396, 473, 380, 82);
		eduPanel.add(memoryList);
		
		TextArea instructionsList = new TextArea();
		instructionsList.setEditable(false);
		instructionsList.setBounds(396, 131, 380, 208);
		eduPanel.add(instructionsList);
		
		JLabel lblInstructions = new JLabel("Instructions:");
		lblInstructions.setBounds(396, 111, 115, 14);
		eduPanel.add(lblInstructions);
	}
}
